﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace OpticalPowerMeter.Converts
{
    /// <summary>
    /// 传入的参数为一个bool值，用于表示是否选中，返回一个Brush用于显示控件底色
    /// 继承与IValueConverter接口
    /// </summary>
    [ValueConversion(typeof(bool),typeof(Brush))]
    public class SelectStatusConvert : IValueConverter
    {
        /// <summary>
        /// 传入的参数为一个bool值，用于表示是否选中，返回一个Brush用于显示控件底色
        /// </summary>
        /// <param name="value">bool表示是否选中</param>
        /// <param name="targetType">未使用</param>
        /// <param name="parameter">未使用</param>
        /// <param name="culture">未使用</param>
        /// <returns>颜色  true - LightGreen  false - WhiteSmoke </returns>
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            bool source = (bool)value;
            if (source)
            {
                return Brushes.LightGreen;
            }
            else
            {
                return Brushes.WhiteSmoke;
            }
        }

        /// <summary>
        /// 接口继承的方法，本地未实现任何内容
        /// </summary>
        /// <param name="value"></param>
        /// <param name="targetType"></param>
        /// <param name="parameter"></param>
        /// <param name="culture"></param>
        /// <returns></returns>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
